﻿@model HelloMinasan.Web.Song.ViewModels.SongViewModels
@{
    ViewBag.Title = "Edit Lyric";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="@Url.Content("~/Content/Js/CommunityFunction.js")"></script>
<script>
    $(document).ready(function () {
        autoResize();
    });
</script>
<div class="contentSection">
    @using (Html.BeginForm())
    {
        @Html.HiddenFor(x => x.SongId)
        <div class="titleSection">
            <img src="@Url.Content("~/Content/Images/exclamation.png")" />
            Posting Attention
        </div>
        <div class="contentSectionInside" style="margin-bottom: 10px;">
            <p>
                <img src="@Url.Content("~/Content/Images/alert.png")" height="20" width="20" />
                Please input information for your song. Your song must follow bellow our policies:
        <ul>
            <li>There is no sex content</li>
            <li>There is no political content</li>
            <li>At least 64Kbps quality (We want to keep our quality service)</li>
        </ul>
                If your file can't follow any section as above policies, we will delete it and inform you by internal message service. Thanks for your attention.
            </p>
        </div>
        <div class="contentSection">
            <div id="lyricRegionSection" style="width:550px;">
                        @foreach (var item in Model.Lyrics)
                        {
                            <div class="titleSection" id="lyricTitle-@item.Song.Id-@item.Language.Id" onclick="showHideLyricSection('lyric-@item.Song.Id-@item.Language.Id', this)">
                                <img src="@Url.Content("~/Content/Images/composer.png")" width="20" height="20"/>
                                <span class="titleTab">@item.Language.Name</span>
                                @if (!item.LyricStatus && item.CanUpdate && Request.IsAuthenticated)
                                {
                                    <a id="edit-@item.Song.Id-@item.Language.Id" onclick="communityEditLyric(this, @item.Song.Id , @item.Language.Id)">
                                        <img src="@Url.Content("~/Content/Images/allowEdit.png")" title="Edit this lyric." /></a>
                                    <a id="save-@item.Song.Id-@item.Language.Id" class="toggleButton" onclick="communitySaveLyric(this, @item.Song.Id , @item.Language.Id)">
                                        <img src="@Url.Content("~/Content/Images/save.png")" title="Edit this lyric." /></a>
                                    <a id="cancel-@item.Song.Id-@item.Language.Id" class="toggleButton" onclick="communityCancelLyric(this, @item.Song.Id , @item.Language.Id)">
                                        <img src="@Url.Content("~/Content/Images/cancel.png")" title="Edit this lyric." /></a>
                                }
                                <div class="tooltipContent">
                                    Last update by <strong>@item.User.Id</strong> on <strong>@item.LastUpdate.ToLongDateString()</strong>
                                </div>
                            </div>
                        }
                        @if (Request.IsAuthenticated)
                        {
                            <div class="titleSection" onclick="createNewLanguage(@Model.SongId)">
                                <img src="@Url.Content("~/Content/Images/document-new.png")" width="20" height="20"/>
                                <div class="tooltipContent">Add new lyric</div>
                            </div>
                        }
                        @if (Model.Lyrics.Any())
                        {
                            bool isFirst = true;
                            foreach (var item in Model.Lyrics)
                            {
                                if (isFirst)
                                { 
                            <textarea id="lyric-@item.Song.Id-@item.Language.Id" readonly="readonly" class="lyricTextArea">@item.LyricContent</textarea>
                                    isFirst = false;
                                }
                                else
                                {
                            <textarea id="lyric-@item.Song.Id-@item.Language.Id" readonly="readonly" class="lyricTextArea" style="display:none">@item.LyricContent</textarea>
                                }
                            }
                        }
                        else
                        {
                            <div class="contentSectionInside">There is no lyric for this song.</div>
                        }
                    </div>
                    <div id="createNewLyricRegion" style="display: none;margin-top:20px;">
                        <div id="comboboxLanguage"></div>
                        <textarea id="newLyricContentCommunity" class="lyricTextArea createLyric"></textarea>
                        <input type="button" onclick="saveCommunityAddNewLyric(@Model.SongId)" value="Save" />
                        <input onclick="cancelCommunityAddNewLyric()" type="button" value="Cancel" />
                    </div>
                    <div id="lyricUpdateIndicator" style="display: none">
                        <img src="@Url.Content("~/Content/Images/loader.gif")" />
                        <br />
                        Please wait while us process your updating...
                    </div>
            @*<div class="contentSection">
                <a href="#">Add new lyric</a>
                <div style="width: 550px;">
                    @for (int i = 0; i < Model.Lyrics.Count; i++)
                    {
                        @Html.HiddenFor(x => x.Lyrics[i].SongId)
                        @Html.HiddenFor(x => x.Lyrics[i].LanguageId)
                        <div class="titleSection" id="lyricTitle-@Model.Lyrics[i].SongId-@Model.Lyrics[i].LanguageId" 
                            onclick="showHideLyricSection('lyric-@Model.Lyrics[i].SongId-@Model.Lyrics[i].LanguageId', this)">
                            <img src="@Url.Content("~/Content/Images/composer.png")" width="20" height="20"/>
                            @Html.TextBoxFor(x => x.Lyrics[i].Language, new { style = "width:60px" })
                        </div>
                    }
                    @if (Model.Lyrics.Any())
                    {
                        bool isFirst = true;

                        for (int i = 0; i < Model.Lyrics.Count; i++)
                        {
                            if (isFirst)
                            { 
                                @Html.TextAreaFor(x => x.Lyrics[i].LyricContent, new { id = "lyric-@item.LyricId", @class = "lyricTextArea" })
                                isFirst = false;
                            }
                            else
                            {
                                @Html.TextAreaFor(x => x.Lyrics[i].LyricContent, new { id = "lyric-@item.LyricId", @class = "lyricTextArea", style = "display:none" })
                            }
                        }
                    }
                    else
                    {
                        <text>// TO DO partial for community</text>
                    }
                </div>
                <input type="submit" value="Submit" />
            </div>*@
        </div>
    }
</div>
